package main

import "fmt"

// 函数版学生管理系统
// 增 删 查功能s

// 自定义类型
type myStudents []student

type student struct {
	id, age              uint
	name, class, address string
}

func (s *myStudents) get() {
	fmt.Println(*s)
}

func (s *myStudents) add(newStu student) {
	*s = append(*s, newStu)
}

func (s *myStudents) deleteById(ids ...int) {
	for _, idsValue := range ids {
		for i, v := range *s {
			if uint(idsValue) == v.id {
				(*s) = append((*s)[:i], (*s)[i+1:]...)
				break
			}
		}
	}
}
func main() {
	var stus = make(myStudents, 0, 1)
	s1 := student{id: 1203, age: 18, name: "学生1", class: "1班", address: "xxxxxx"}
	s2 := student{id: 1211, age: 20, name: "学生2", class: "1班", address: "xxxxxx"}
	s3 := student{id: 1230, age: 18, name: "学生3", class: "1班", address: "xxxxxx"}

	stus.add(s1)
	stus.add(s2)
	stus.add(s3)
	stus.deleteById(1203)
	stus.get() // [{1211 20 学生2 1班 xxxxxx} {1230 18 学生3 1班 xxxxxx}]
}
